package com.leetcode.two_pointers;

/**
 * @author Dennis Li
 * @date 2020/7/18 15:41
 */
public class TwoSum_167 {

    public int[] twoSum(int[] numbers, int target) {
        int i = 0, j = numbers.length - 1;
        while (numbers[i] + numbers[j] != target) {
            if (numbers[i] + numbers[j] > target) {
                j--;
                i = i > 0 ? i - 1 : 0;
            } else i++;
        }
        return new int[]{i + 1, j + 1};
    }

}
